import {
    center,
    grid,
    header,
    button,
    search,
} from '@/css/VueCss.module.scss' ;

export default {
    title: '客户列表',
    items: [{
        region: 'center',
        class: center,
        layout: 'vertical',
        items: [{
            items: [{
                id: 'search',
                class: search,
                widget: 'search-datesearch',
                times: [{
                    label: '今日',
                    value: 'today'
                }, {
                    label: '昨日',
                    value: 'yesterday'
                }, {
                    label: '近7日',
                    value: 'lately7'
                }, {
                    label: '近30日',
                    value: 'lately30'
                }],
                rangeTimes: true,
                selects: [{
                    field: 'source_uuid',
                    placeholder: '请选择客户来源',
                    dictionary: {
                        path: 'common/dictionary/config',
                        params: {
                            name: 'crm_customer_source'
                        },
                    }
                }],
                text: {
                    field: 'keywords',
                    placeholder: '请输入客户(公司)'
                },
                onSearch: [{
                    action: 'grid-load',
                    target: '$widgets.grid',
                    params: {
                        page_size: '$widgets.grid.pageSize',
                        keywords: '$params.keywords',
                        source_uuid: '$params.source_uuid',
                        industry_uuid: '$params.industry_uuid',
                    }
                }]
            }, {
                class: header,
                layout: 'horizontal',
                items: [{
                    class: button,
                    type: 'primary',
                    plain: true,
                    widget: 'button',
                    value: '客户导入',
                    onClick: [{
                        action: 'dialog-show',
                        path: 'CustomersPool/Temporary/Import',
                        params: {
                            title: "'客户导入'",
                        },
                        applyActions: [{
                            action: 'call',
                            target: '$widgets.grid',
                            method: 'reload'
                        }],
                        cancelActions: [{
                            action: 'print',
                            description: '取消对话框'
                        }]
                    }]
                }, {
                    class: button,
                    type: 'danger',
                    plain: true,
                    widget: 'button',
                    value: '转入公共客户池',
                    onClick: [{
                        action: 'confirm',
                        title: '转入公共客户池',
                        message: '是否将选中数据转入公共客户池?',
                        confirm: [{
                            var: 'checkedItemIds',
                            action: 'array-value',
                            target: '$widgets.grid.checkedItems',
                            key: 'id'
                        }, {
                            action: 'service',
                            path: 'customers_pool/temporary/customer/roll_out',
                            params: {
                                ids: '$vars.checkedItemIds'
                            }
                        }, {
                            action: 'call',
                            target: '$widgets.grid',
                            method: 'reload'
                        }, {
                            action: 'dialog-hide',
                            mode: 'apply'
                        }]
                    }]
                }]
            }]
        }, {
            id: 'grid',
            class: grid,
            widget: 'grid',
            service: {
                path: 'customers_pool/temporary/customer/list',
                params: {
                    state: '0',
                }
            },
            pageSize: 20,
            columns: [{
                prop: 'status_uuid',
                label: '回访状态',
                dictionary: {
                    path: 'common/dictionary/config',
                    params: {
                        name: 'return_visit_status',
                    },
                },
                width: 120
            }, {
                prop: 'source_uuid',
                label: '客户来源',
                width: 120
            }, {
                prop: 'corporate_name',
                label: '客户名称(公司)',
                minWidth: 280
            }, {
                prop: 'operate_status',
                label: '登记状态',
                width: 80
            }, {
                prop: 'legal_representative',
                label: '法定代表人',
                width: 120
            }, {
                prop: 'registered_capital',
                label: '注册资本',
                width: 120
            }, {
                prop: 'establishment_date',
                label: '成立时间',
                width: 120
            }, {
                prop: 'telephone',
                label: '电话',
                width: 140
            }, {
                prop: 'email',
                label: '邮箱',
                width: 160
            }, {
                prop: 'website',
                label: '网站',
                width: 160
            }, {
                prop: 'province',
                label: '所属省份',
                minWidth: 80
            }, {
                prop: 'city',
                label: '所属城市',
                minWidth: 80
            }, {
                prop: 'county',
                label: '所属区县',
                minWidth: 80
            }],
            buttons: [{
                value: '详情',
                onClick: [{
                    action: 'dialog-show',
                    path: 'CustomersPool/Temporary/Details',
                    params: '$params',
                }]
            }, {
                value: '删除',
                type: 'danger',
                onClick: [{
                    action: 'confirm',
                    title: '删除数据',
                    message: '是否删除该条数据?',
                    confirm: [{
                        action: 'service',
                        path: 'customers_pool/temporary/customer/remove',
                        params: {
                            id: '$params.id'
                        }
                    }, {
                        action: 'call',
                        target: '$widget',
                        method: 'reload'
                    }]
                }]
            }],
            flex: true,
            enableCheckboxColumn: true,
        }]
    }]
};
